package me.jzn.alib.drawable;

import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RemoteViews;

import androidx.annotation.ColorInt;
import androidx.annotation.IdRes;

public class ColorDrawableType implements DrawableType {
    @ColorInt
    private int color;

    public ColorDrawableType(@ColorInt int color) {
        this.color = color;
    }

    @ColorInt
    public int getColor() {
        return color;
    }

    @Override
    public Drawable getDrawable() {
        return new ColorDrawable(color);
    }

    @Override
    public void setImageView(ImageView iv) {
        throw new UnsupportedOperationException("ImageView不支持color作为前景,请试试setBackground(color)");
    }

    @Override
    public void setBackground(View view) {
        view.setBackgroundColor(color);
    }

    @Deprecated
    @Override
    public void setRemoteViews(RemoteViews rv, @IdRes int imageViewId) {
        throw new UnsupportedOperationException("remoteviews不支持color类型");
    }
}
